﻿<%@ Page Title="" Language="C#" EnableEventValidation="false" MasterPageFile="~/Portal/Master/Portal.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Besture.UI.Portal.UserCenter.Register" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="stylesheet" href="/Resource/css/normalize.css" />
    <link rel="stylesheet" href="/Resource/css/common.css" />
    <link rel="stylesheet" href="/Resource/css/base.css" />
    <link href="/Resource/css/index.css" rel="stylesheet" />
    <link href="/Resource/css/qa.css" rel="stylesheet" />
    <link href="/Resource/source/FancyBox/jquery.fancybox.css" rel="stylesheet" />
    <script type="text/javascript" src="/Resource/source/FancyBox/jquery.fancybox.js"></script>
    <style>
        .error {
            left: 8px;
            top: 0;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <div class="wrap">
        <div class="main">
            <form>
                <div class="main_login">
                    <div class="login_body login">
                        <div class="login_body_content">
                            <div class="tar">
                                <div class="register_phone">
                                    <div class="title1 user">会员注册</div>
                                    <div class="getlogin1">已有账号？<a href="Login.aspx">立即登录</a></div>
                                    <br class="clear" />
                                    <div class="register_body">
                                        <div class="phone_num">手&nbsp;机&nbsp;号</div>
                                        <div class="phone_number">
                                            <input id="txtTelphone" runat="server" class="num mobile maxlength" maxlength="11" name="phone" />
                                        </div>
                                    </div>
                                    <div class="register_body">
                                        <div class="phone_num">校&nbsp;验&nbsp;码</div>
                                        <div class="phone_number1">
                                            <input id="registerCode" runat="server" class="num" name="code" type="password" />
                                            <a href="#" class="getphonecode">免费获取验证码</a>
                                        </div>
                                    </div>
                                    <div class="register_body">
                                        <div class="phone_num">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮&nbsp;箱</div>
                                        <div class="phone_number">
                                            <input id="txtemail" runat="server" name="email" class="num" />
                                        </div>
                                    </div>
                                    <div class="register_body">
                                        <div class="phone_num">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</div>
                                        <div class="phone_number">
                                            <input id="registerPwd" runat="server" class="num" name="pwd" type="password" />
                                        </div>
                                    </div>
                                    <div class="register_body">
                                        <div class="phone_num">确认密码</div>
                                        <div class="phone_number">
                                            <input id="registerPwdSure" runat="server" class="num" name="pwd2" type="password" />
                                        </div>
                                    </div>
                                    <div class="checkbox">
                                        <label>
                                            <input type="checkbox" />
                                            我已经阅读并同意</label>
                                        <a href="javascript:void(0)" class="clause">《翔盛服务条款》</a>
                                    </div>
                                    <input runat="server" onserverclick="LoginClick" type="submit" class="subimt1" value="注  册" />
                                </div>

                            </div>
                        </div>
                    </div>
                </div>

                <!--弹窗-->
                <div class="affirm_main dealer-con" style="display: none; position: absolute; left: 28%; margin-right: 320px; top: 23%; z-index: 10; height: 270px;">
                    <div class="terms">
                         <%=sDetail %>
                    </div>
                    <p class="close"><a href="#" class="sub">关&nbsp;闭</a></p>
                </div>
                <!--遮罩-->
                <img src="/Resource/images/mask-bg.png" style="display: none" />
                <div class="mask" style="position: absolute; left: 0; top: 0; width: 100%; background: url(/Resource/images/mask-bg.png) repeat left top; display: none;"></div>
            </form>
        </div>
        <!-- //main -->
    </div>
    <!-- //wrap -->
    <script type="text/javascript" src="/Resource/js/jquery.validate.js"></script>
    <script type="text/javascript">
        $(function () {

            $(".subimt1").click(function() {

                if ($("#<%=txtTelphone.ClientID %>").val().length > 0) {
                    if ($("input[type='checkbox']").attr("checked") !== "checked") {
                        alert("请选择服务条款");
                        return false;
                    }
                    //校验短信验证码 是否正确 
                    var v = <%=(string) Session["registerPhoneCode"] !=""?Session["registerPhoneCode"]:"0" %>;
                    if (parseInt($("#<%=registerCode.ClientID%>").val()) !== v) {
                        alert("请输入正确验证码");
                        return false;
                    }
                }
            }); 

            //发送手机验证码
            var isSendingPhoneCode = false;
            $(".getphonecode").click(function () {
                if ($("#<%=txtTelphone.ClientID %>").val().length > 0) {
                    if (isSendingPhoneCode) return false;
                    isSendingPhoneCode = true;
                    var _this = $(this);
                    var time = 60;
                    var text = $(this).text();
                    var t = setInterval(function() {
                        time--;
                        if (time == 0) {
                            clearInterval(t);
                            isSendingPhoneCode = false;
                            _this.text(text);
                        } else {
                            _this.text(time + "秒后重新发送");
                            //发送手机验证码--操作
                            $.post("/Portal/UserCenter/AjaxUserInfo.aspx", { "Phone": $("#<%=txtTelphone.ClientID%>").val(), "requestMethod": "PhoneSendSmsSend" }, function(data) {
                                //手机验证码已经发送 
                            });
                        }
                    }, 1000);
                    return false;
                }
            });

            $("form").validate({
                rules: {
                    ctl00$Content$txtTelphone: {
                        required: true
                    },
                    ctl00$Content$registerPwd: {
                        required: true,
                        minlength: 6,
                        maxlength: 16
                    },
                    ctl00$Content$registerPwdSure: {
                        required: true,
                        equalTo: "#ctl00_Content_registerPwd"
                    }
                },
                messages: {
                    ctl00$Content$txtTelphone: {
                        required: "请输入手机号！"
                    },
                    ctl00$Content$registerPwd: {
                        required: "请输入密码！",
                        minlength: "密码至少6位",
                        maxlength: "密码不能超过16位"
                    },
                    ctl00$Content$registerPwdSure: {
                        required: "请输入确认密码！",
                        equalTo: "两次密码输入不一致"
                    } 
                },
                highlight: function (element, errorClass, validClass) {
                },
                unhighlight: function (element, errorClass, validClass) {
                }
            });
             


            //弹窗
            $(".clause").fancybox();
            $(".clause").live("click", function (e) {
                $(".mask").height($(document).height());
                $(".mask").fadeIn(function () {
                    $(".affirm_main").fadeIn();
                });
                e.stopPropagation();
            });

            $(".close .sub").click(function () {
                $(this).parent().parent().fadeOut();
                $(".mask").fadeOut();
                $("input:checkbox").attr("checked", true);
            });

            //异步判断手机号是否唯一
            $("#<%=txtTelphone.ClientID %>").blur(function () {
                if ($("#<%=txtTelphone.ClientID %>").val().length > 0) {
                    $.post("/Portal/UserCenter/AjaxUserInfo.aspx", { "requestMethod": "ajax_phone", "UserType": "1", "Phone": $("#<%=txtTelphone.ClientID%>").val() }, function(data) {
                        if (data > 0) {
                            alert("该手机号已被注册");
                            return false;
                        }
                        return true;
                    });
                }
            });

            //异步判断邮箱是否唯一
            $("#<%=txtemail.ClientID %>").blur(function () {
                if ($("#<%=txtemail.ClientID %>").val().length > 0) {
                    $.post("/Portal/UserCenter/AjaxUserInfo.aspx", { "requestMethod": "ajax_email", "UserType": "1", "Email": $("#<%=txtemail.ClientID %>").val() }, function(data) {
                        if (data > 0) {
                            alert("该邮箱已被注册");
                            return false;
                        }
                        return true;
                    });
                }
            });

        });

    </script>
</asp:Content>
